<!--
 * @Author: liuyonghu
 * @Date: 2021-11-12 17:24:14
 * @LastEditTime: 2021-11-12 17:53:36
 * @LastEditors: liuyonghu
 * @Description: 
 * @FilePath: /demos/iframe/index.html
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>index</title>
  </head>
  <body>
    <iframe
      onload="iframeOnload(event)"
      id="iframe"
      src="http://127.0.0.1:8082/iframe.html"
      frameborder="0"
    ></iframe>

    <script>
      function iframeOnload(e) {
        const myIframe = document.querySelector("#iframe");
        const y = myIframe.contentWindow || myIframe.contentDocument;
        console.log(y);
        console.log(y.top.innerWidth);
        const height = y.top.innerWidth;
        myIframe.style.height = height + "px"
      }
    </script>
  </body>
</html>
